package com.ruoyi.washer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.washer.domain.XwEnduser;
import com.ruoyi.washer.service.IXwEnduserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 终端经营用户Controller
 * 
 * @author hawking
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/washer/enduser")
public class XwEnduserController extends BaseController
{
    @Autowired
    private IXwEnduserService xwEnduserService;

    /**
     * 查询终端经营用户列表
     */
    @PreAuthorize("@ss.hasPermi('washer:enduser:list')")
    @GetMapping("/list")
    public TableDataInfo list(XwEnduser xwEnduser)
    {
        startPage();
        List<XwEnduser> list = xwEnduserService.selectXwEnduserList(xwEnduser);
        return getDataTable(list);
    }

    /**
     * 导出终端经营用户列表
     */
    @PreAuthorize("@ss.hasPermi('washer:enduser:export')")
    @Log(title = "终端经营用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XwEnduser xwEnduser)
    {
        List<XwEnduser> list = xwEnduserService.selectXwEnduserList(xwEnduser);
        ExcelUtil<XwEnduser> util = new ExcelUtil<XwEnduser>(XwEnduser.class);
        util.exportExcel(response, list, "终端经营用户数据");
    }

    /**
     * 获取终端经营用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('washer:enduser:query')")
    @GetMapping(value = "/{enduserId}")
    public AjaxResult getInfo(@PathVariable("enduserId") Long enduserId)
    {
        return success(xwEnduserService.selectXwEnduserByEnduserId(enduserId));
    }

    /**
     * 新增终端经营用户
     */
    @PreAuthorize("@ss.hasPermi('washer:enduser:add')")
    @Log(title = "终端经营用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XwEnduser xwEnduser)
    {
        return toAjax(xwEnduserService.insertXwEnduser(xwEnduser));
    }

    /**
     * 修改终端经营用户
     */
    @PreAuthorize("@ss.hasPermi('washer:enduser:edit')")
    @Log(title = "终端经营用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XwEnduser xwEnduser)
    {
        return toAjax(xwEnduserService.updateXwEnduser(xwEnduser));
    }

    /**
     * 删除终端经营用户
     */
    @PreAuthorize("@ss.hasPermi('washer:enduser:remove')")
    @Log(title = "终端经营用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{enduserIds}")
    public AjaxResult remove(@PathVariable Long[] enduserIds)
    {
        return toAjax(xwEnduserService.deleteXwEnduserByEnduserIds(enduserIds));
    }
}
